home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / FlyThrough 1.1.2 / src / Source / Misc Utilities / CGetKeys.h < prev    next >
Encoding:
Text File  |  1996-07-11  |  716 b   |  40 lines  |  [TEXT/CWIE]

  1. //
  2. //    CGetKeys.h
  3. //
  4. //    A class the encapsulates the GetKeys() toolbox call.
  5. //    Allows the testing of many keys with only one call to GetKeys().
  6. //
  7. //    by James Jennings
  8. //    July 11, 1996
  9. // Events.h
  10.  
  11. #pragma once
  12.  
  13. enum EKeyCode {
  14.     code_Command        = 0x37,
  15.     code_Shift            = 0x38,
  16.     code_ShiftLock        = 0x39,
  17.     code_Option            = 0x3A,
  18.     code_Control        = 0x3B,
  19.     
  20.     code_LeftArrow        = 0x7B,
  21.     code_RightArrow        = 0x7C,
  22.     code_UpArrow        = 0x7E,
  23.     code_DownArrow        = 0x7D
  24.     };
  25.  
  26. class CGetKeys {
  27. public:
  28.     CGetKeys() { ::GetKeys( mKeys ); }
  29.     Boolean    IsDown( Char16 inKeyCode );
  30. protected:
  31.     KeyMap mKeys;
  32. };
  33.  
  34. inline
  35. Boolean CGetKeys::IsDown( Char16 inKeyCode )
  36. {
  37.     return (BitTst(((char*) &mKeys) + inKeyCode / 8, (long) 7 - (inKeyCode % 8) ) );
  38. }
  39.  
  40.